<%@ include file="IsStudent.jsp"%>
<%@ page import="java.util.*,java.sql.*,database.*" %>

<%
try{		String add = request.getParameter("add"), rmv = request.getParameter("remove");
		String[] proj = {request.getParameter("proj1"), request.getParameter("proj2"), request.getParameter("proj3"),    
		  };
DBCon db = new DBCon();

		db.deleteChoosedProject("WHERE studentId=" + session.getAttribute("id"));

		if (add != null) {
			for (int i = 0; i < 3; i++) {
				if (!(proj[0].equals(proj[1]) || proj[1].equals(proj[2]) || proj[0].equals(proj[2]))) {
					db.insertProjectChoose(proj[i], ""+session.getAttribute("id"), ""+(i+1));
				}

			}

		}
		response.sendRedirect("../Student/myChoice.jsp");
		}
catch(Exception e)
{
    response.sendRedirect("../connectionFailed.jsp?"+e);
}

%>
